﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SD.DataAccess;
using SD.Business;
using System.Drawing;

namespace SD.Web.Views.Government
{
    public partial class CreateGovOfficeRegion : System.Web.UI.Page
    {
        /// <summary>
        /// The page load method
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">event arg</param>
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        /// <summary>
        /// Back button event
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">event arg</param>
        protected void ButtonBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Views/Government/GovOfficeRegionList.aspx");
        }

        /// <summary>
        /// Save button event
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">event arg</param>
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            LabelMessage.ForeColor = Color.Red;
            string name = TextBoxName.Text.Trim();

            try
            {
                GovOfficeRegion gor = new GovOfficeRegion();
                gor.GovOfficeRegionName = name;
                gor.Description = TextBoxDescription.Text;
                gor.IsActive = true;
                if (!GovOfficeRegionBus.Add(gor))
                {
                    throw new Exception("The system is not responding now, please try again later!");
                }
                LabelMessage.ForeColor = Color.BlueViolet;
                LabelMessage.Text = "Saving successfully! You can continue to add another new one...";
                TextBoxName.Text = "";
                TextBoxDescription.Text = "";
            }
            catch (Exception ex)
            {
                LabelMessage.Text = ex.Message;
            }
        }
    }
}